﻿using MediatR;
using SystemLYH.API.Application.Command.ReservoirCommand;
using SystemLYH.Domain;
using SystemLYH.Infrstructre.Interface;

namespace SystemLYH.API.Application.Handlers.ReservoirHandlers
{
    public class ReservoirCreateHandlesr : IRequestHandler<ReservoirCreateCommand, int>
    {
        protected readonly IReservoirRepository _reservoirRepository;
        /// <summary>
        /// 库区构造函数
        /// </summary>
        /// <param name="reservoirRepository"></param>
        public ReservoirCreateHandlesr(IReservoirRepository reservoirRepository)
        {
            _reservoirRepository = reservoirRepository;
        }

        public async Task<int> Handle(ReservoirCreateCommand request, CancellationToken cancellationToken)
        {
            return await _reservoirRepository.CreaseAsync(new Reservoir()
            {
                ReservoirName=request.ReservoirName,
                ReservoirNumber=request.ReservoirNumber,
                ReservoirArea=request.ReservoirArea,
                ReservoirRemark=request.ReservoirRemark,
                WarehouseID=request.WarehouseID,
                AddName="李子坤",
                AddTime=DateTime.Now.ToUniversalTime(),
            });
        }
    }
}
